package net.chromedpork.hypertext.client;



import java.util.Map;



/**
 *
 *  Fabricator of HTTP{S} clients.
 *
 *  @author Inode <inode@chromedpork.net>
 *
 */


public class ClientFactory
{
    /**
     *
     *  Generates an 'empty' HTTP client.
     *
     *  @return client object
     *
     */

    public static Client getClient()
    {
        return (new Client());
    }



    /**
     *
     *  Generates an HTTP client preconfigured to request a URL with
     *  the GET method.
     *
     *  @return client object
     *
     *  @throws ClientException
     * 
     */
    
    public static Client getClient(String url)
                  throws ClientException
    {
        return (new Client(url));
    }



    /**
     *
     *  Generates an HTTP client preconfigured to request a URL with
     *  the prescribed method.
     *
     *  @return client object
     *
     *  @throws ClientException
     *
     */
    
    public static Client getClient(String method,
                                   String url)
                  throws ClientException
    {
        return (new Client(method, url));
    }


    
    /**
     *
     *  Generates an HTTP client preconfigured to request a URL with
     *  the prescribed method, and payload data.
     *
     *  @return client object
     *
     *  @throws ClientException
     *
     */

    public static Client getClient(String method,
                                   String url,
                                   String payload)
                  throws ClientException
    {
        return (new Client(method, url, payload));
    }



    /**
     *
     *  Generates an HTTP client preconfigured to request a URL with
     *  the prescribed method, and request headers.
     *
     *  @return client object
     *
     *  @throws ClientException
     *
     */
    
    public static Client getClient(String method,
                                   String url,
                                   Map<String, String> headers)
                  throws ClientException
    {
        return (new Client(method, url, headers));
    }



    /**
     *
     *  Generates an HTTP client preconfigured to request a URL with
     *  the prescribed method, payload data and request headers.
     *
     *  @return client object
     *
     *  @throws ClientException
     *
     */
    
    public static Client getClient(String method,
                                   String url,
                                   Map<String, String> headers,
                                   String payload)
                  throws ClientException
    {
        return (new Client(method, url, headers, payload));
    }
}
